import logging.config

from config.logconfig import LOGGING_DIC

logging.config.dictConfig(LOGGING_DIC)  # 导入上面定义的logging配置
logger = logging.getLogger(__name__)  # 生成一个log实例
from config.mysql_config import mysql

def chack_terminal_info(num):
    """查询终端的真实性信息"""
    """获得中石化所有车辆的信息"""
    with mysql() as cursor:

        ip_list = []
        sql = "select terminal_ip from terminal_info"
        try:
            cursor.execute(sql)

            res = cursor.fetchall()
        except Exception as e:
            logger.error(e)

        for ip in res:
            # print(ip["terminal_ip"])

            ip_list.append(ip["terminal_ip"])


        # print(res)

        if num in ip_list:
            return 1
        else:
            return 0



